//
//  BluetoothModel.h
//  BLEDemo
//
//  Created by kingunionLCF on 2019/9/11.
//  Copyright © 2019 kingunionLCF. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import <BabyBluetooth.h>

NS_ASSUME_NONNULL_BEGIN

/**
 设备名称
 */
#define PMServiceName @"ST"
/**
 设备读取UUID
 */
#define PMServiceUUID_Receive @"FFE5"
/**
 设备写入UUID
 */
#define PMServiceUUID_Send @"FFE6"

@protocol BluetoothModelDelegate <NSObject>

@optional

/**
 更新扫描到的蓝牙列表

 @param peripheralDataArray 蓝牙设备
 */
-(void)updateTableViewPeripheralDataArray:(NSArray *)peripheralDataArray;

/**
 连接成功
 */
-(void)connectionSucceeded;

/**
 连接失败
 */
-(void)connectionFailed;

/**
 断开连接
 */
-(void)disconnect;

@end

@interface BluetoothModel : NSObject

@property (nonatomic,weak)id<BluetoothModelDelegate>delegate;

+(instancetype)sharedInstance;



/**
 扫描外设
 */
-(void)startScanningPeripherals;

/**
 停止扫描外设
 */
-(void)stopScanningPeripherals;

/**
 连接蓝牙设备

 @param peripheral <#peripheral description#>
 */
-(void)connectToBluetoothCBPeripheral:(CBPeripheral *)peripheral;

/**
 取消所有连接
 */
-(void)cancelAllConnection;






@property (nonatomic,strong)CBPeripheral *peripheral;
@property (nonatomic,strong)CBCharacteristic *writeCharacteristics;
@property (nonatomic,strong)CBCharacteristic *readCharacteristics;


@end

NS_ASSUME_NONNULL_END
